//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#include "Generador.h"

Define_Module(Generador);

Generador::Generador()
{
	sendMessageEvent = NULL;
}

Generador::~Generador()
{
	cancelAndDelete(sendMessageEvent);
}

void Generador::initialize()
{
	sendMessageEvent = new cMessage("sendMessageEvent");
	scheduleAt(simTime(),sendMessageEvent);
	generados = 0;
	ev << "- PRODUCTOR - inizializado productor" << endl;
}

void Generador::handleMessage(cMessage *msg)
{
ASSERT(msg==sendMessageEvent);
	cMessage *persona = new cMessage("persona");
	send(persona,"salida");
	interarribos = par("tiempoLlegadas");
	scheduleAt(simTime()+interarribos,sendMessageEvent);
	generados++;
}

void Generador::finish(){
	ev << "----------------ESTADISTICOS DE LA CLASE: " << this->getName() << endl;
	ev << "total personas generadas: " << generados << endl << endl;
}
